package com.example.apidocserver.infrastructure.util.user;

import com.example.apidocserver.application.dto.UserDocInfoDto;
import com.example.apidocserver.infrastructure.config.security.UserDetailsImpl;

/**
 * 静态用户工具类
 *
 * @author xyqlg
 */
public class CurrentUser {
    private static final ThreadLocal<UserDetailsImpl> USER_DETAILS_THREAD_LOCAL = new ThreadLocal<>();

    public static void setUser(UserDetailsImpl userDetails) {
        USER_DETAILS_THREAD_LOCAL.set(userDetails);
    }

    public static UserDetailsImpl getUser() {
        return USER_DETAILS_THREAD_LOCAL.get();
    }

    public static void remove() {
        USER_DETAILS_THREAD_LOCAL.remove();
    }
}
